/* Editor.java
 * Created on Sep 7, 2010, 3:40:12 PM
 */

package ResultEditor.SimpleSchema;

import Relationship.Simple.DataTypes.Attribute;
import java.util.HashSet;
import java.util.Vector;

/**
 * This Class will be used to Edit the Attributes within the current schema.
 *
 * @see     env.AttributeList
 * @see     env.Attribute
 * @author  Jianwei Chris Leng
 *
 * Created on Sep 7, 2010, 3:40:12 PM
 */

public class Editor extends javax.swing.JFrame {
    //<editor-fold defaultstate="collapsed" desc="Member Variables">
    UserInterface.GUI gui;
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Constructor">
    /**
     * Constructor
     * @param caller - the UserInterface.GUI that is creating this editor.
     */
    public Editor(UserInterface.GUI caller) {
        initComponents();
        this.setSize(400, 500);
        updateRelationships();
        
        gui = caller;
        setDialogLocation();

    }
    //</editor-fold>

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        changeAttributeName = new javax.swing.JDialog();
        jTestField_attributeName = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        removeName = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        nameText = new javax.swing.JTextField();
        addName = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        attributeNames = new javax.swing.JList();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        removeValue = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        valueText = new javax.swing.JTextField();
        addValue = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        attributeValues = new javax.swing.JList();

        changeAttributeName.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        changeAttributeName.setAlwaysOnTop(true);
        changeAttributeName.setBackground(new java.awt.Color(238, 238, 239));

        jTestField_attributeName.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N

        jLabel3.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        jLabel3.setText("Attribute Name:");

        jButton2.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        jButton2.setText("OK");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton4.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        jButton4.setText("Cancel");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout changeAttributeNameLayout = new javax.swing.GroupLayout(changeAttributeName.getContentPane());
        changeAttributeName.getContentPane().setLayout(changeAttributeNameLayout);
        changeAttributeNameLayout.setHorizontalGroup(
            changeAttributeNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(changeAttributeNameLayout.createSequentialGroup()
                .addGroup(changeAttributeNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(changeAttributeNameLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3)
                        .addGap(5, 5, 5)
                        .addComponent(jTestField_attributeName, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, changeAttributeNameLayout.createSequentialGroup()
                        .addContainerGap(224, Short.MAX_VALUE)
                        .addComponent(jButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        changeAttributeNameLayout.setVerticalGroup(
            changeAttributeNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(changeAttributeNameLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(changeAttributeNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTestField_attributeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(changeAttributeNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton4))
                .addContainerGap(213, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Attribute Editor");
        setMinimumSize(new java.awt.Dimension(500, 400));

        jPanel1.setLayout(new java.awt.GridLayout(1, 2, 10, 10));

        jPanel2.setLayout(new java.awt.BorderLayout());

        jPanel9.setLayout(new java.awt.BorderLayout());

        jPanel10.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel10.setLayout(new java.awt.GridLayout(2, 0));

        jPanel11.setLayout(new java.awt.BorderLayout());

        removeName.setFont(new java.awt.Font("Calibri", 0, 13));
        removeName.setText("Remove Selected");
        removeName.setToolTipText("<html>Remove the attribute that is selected in the list. Any allowable values<br> associated with the annotation will also be deleted.</html>");
        removeName.setEnabled(false);
        removeName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeNameActionPerformed(evt);
            }
        });
        jPanel11.add(removeName, java.awt.BorderLayout.CENTER);

        jPanel10.add(jPanel11);

        jPanel12.setLayout(new java.awt.BorderLayout());

        nameText.setFont(new java.awt.Font("Calibri", 0, 13));
        nameText.setToolTipText("<html>Type the name of a new Attribute here.<br> Add to the list by pressing enter or the 'Add' button.</html>");
        nameText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                nameTextKeyPressed(evt);
            }
        });
        jPanel12.add(nameText, java.awt.BorderLayout.CENTER);

        addName.setFont(new java.awt.Font("Calibri", 0, 13));
        addName.setText("Add");
        addName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addNameActionPerformed(evt);
            }
        });
        jPanel12.add(addName, java.awt.BorderLayout.LINE_END);

        jPanel10.add(jPanel12);

        jPanel9.add(jPanel10, java.awt.BorderLayout.PAGE_END);

        jPanel13.setLayout(new java.awt.BorderLayout());

        jPanel14.setBackground(new java.awt.Color(102, 153, 255));
        jPanel14.setLayout(new java.awt.BorderLayout());

        jLabel2.setFont(new java.awt.Font("Calibri", 1, 13));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Attribute Types");
        jPanel14.add(jLabel2, java.awt.BorderLayout.CENTER);

        jPanel13.add(jPanel14, java.awt.BorderLayout.PAGE_START);

        jScrollPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        attributeNames.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N
        attributeNames.setToolTipText("<html>The list of attributes that are allowed within this schema.</html>");
        attributeNames.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                attributeNamesMouseReleased(evt);
            }
        });
        attributeNames.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                attributeNamesValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(attributeNames);

        jPanel13.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel9.add(jPanel13, java.awt.BorderLayout.CENTER);

        jPanel2.add(jPanel9, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel2);

        jPanel3.setLayout(new java.awt.BorderLayout());

        jPanel4.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel4.setLayout(new java.awt.GridLayout(2, 0));

        jPanel6.setLayout(new java.awt.BorderLayout());

        removeValue.setFont(new java.awt.Font("Calibri", 0, 13));
        removeValue.setText("Remove Selected");
        removeValue.setToolTipText("<html>Remove the allowable value that is selected in the list.</html>");
        removeValue.setEnabled(false);
        removeValue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeValueActionPerformed(evt);
            }
        });
        jPanel6.add(removeValue, java.awt.BorderLayout.CENTER);

        jPanel4.add(jPanel6);

        jPanel7.setLayout(new java.awt.BorderLayout());

        valueText.setFont(new java.awt.Font("Calibri", 0, 13));
        valueText.setToolTipText("<html>Type an allowable value for the currently selected attribute type.<br>  Add to the list by pressing enter or the \"Add\" button.");
        valueText.setEnabled(false);
        valueText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                valueTextKeyPressed(evt);
            }
        });
        jPanel7.add(valueText, java.awt.BorderLayout.CENTER);

        addValue.setFont(new java.awt.Font("Calibri", 0, 13));
        addValue.setText("Add");
        addValue.setToolTipText("<html>Add a value to the currently selected Attribute</html>");
        addValue.setEnabled(false);
        addValue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addValueActionPerformed(evt);
            }
        });
        jPanel7.add(addValue, java.awt.BorderLayout.LINE_END);

        jPanel4.add(jPanel7);

        jPanel3.add(jPanel4, java.awt.BorderLayout.PAGE_END);

        jPanel5.setLayout(new java.awt.BorderLayout());

        jPanel8.setBackground(new java.awt.Color(51, 153, 255));
        jPanel8.setLayout(new java.awt.BorderLayout());

        jLabel1.setFont(new java.awt.Font("Calibri", 1, 13));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Allowable Values");
        jPanel8.add(jLabel1, java.awt.BorderLayout.CENTER);

        jPanel5.add(jPanel8, java.awt.BorderLayout.PAGE_START);

        jScrollPane2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        attributeValues.setFont(new java.awt.Font("Calibri", 0, 13));
        attributeValues.setToolTipText("<html> The list of values that are allowed for the selected attribute.</html>");
        attributeValues.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                attributeValuesValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(attributeValues);

        jPanel5.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jPanel3.add(jPanel5, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel3);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //<editor-fold defaultstate="collapsed" desc="Event Handling">
    /**
     * Call this whenever the currently selected attribute is changed.  If an
     * attribute name is selected enable deletion, and enable addition of Attribute
     * values.  If nothing is selected then disable this actions.
     * @param evt
     */
    private void attributeNamesValueChanged(javax.swing.event.ListSelectionEvent evt)//GEN-FIRST:event_attributeNamesValueChanged
    {//GEN-HEADEREND:event_attributeNamesValueChanged
        Object[] values = attributeNames.getSelectedValues();
        Attribute value = null;
        if(values.length > 0)
            value = (Attribute)values[0];
        else
            return;
        

        if(values.length == 1)
        {
            //Enable deletion of Attributes
            removeName.setEnabled(true);
            
            //Enable Editing of Allowable Values
            valueText.setEnabled(true);
            addValue.setEnabled(true);
            
            //Update list of allowable values for this attribute
            updateInList(value);
        }
        else if(values.length > 1)
        {
            //Enable deletion of Attributes
            removeName.setEnabled(true);

            //Enable Editing of Allowable Values
            valueText.setEnabled(false);
            addValue.setEnabled(false);
            
            //Clear out list of attribute values
            attributeValues.setListData(new Vector());
        }
        else
        {
            //Disable deletion of Attributes
            removeName.setEnabled(false);

            //Disable allowable value editing
            valueText.setEnabled(false);
            addValue.setEnabled(false);
            
            //Clear out list of attribute values
            attributeValues.setListData(new Vector());

        }

    }//GEN-LAST:event_attributeNamesValueChanged
    /**
     * When the 'Add' button is pressed under the List of Attribute names, add
     * the current text as a new name.
     * @param evt
     */
    private void addNameActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addNameActionPerformed
    {//GEN-HEADEREND:event_addNameActionPerformed
        addNewRelationshipFromTextBox();
    }//GEN-LAST:event_addNameActionPerformed
    /**
     * When the 'Add' button under the list of allowable values is pressed, add the
     * text in the textbox next to it as a new allowable value.
     * @param evt
     */
    private void addValueActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addValueActionPerformed
    {//GEN-HEADEREND:event_addValueActionPerformed
        addNewAllowableFromTextBox();
    }//GEN-LAST:event_addValueActionPerformed
    /**
     * When the remove button under the Attribute list is pressed remove the currently
     * selected attribute name.
     * @param evt
     */
    private void removeNameActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_removeNameActionPerformed
    {//GEN-HEADEREND:event_removeNameActionPerformed
        Object[] atts = attributeNames.getSelectedValues();
        if(atts == null || atts.length == 0)
            return;
        for(Object att: atts)
            env.Parameters.SimpleRelationshipNames.Remove((Attribute)att);
        attributeValues.setListData(new Vector());
        updateRelationships();
    }//GEN-LAST:event_removeNameActionPerformed

    /**
     * Remove the currently selected value from the list of allowable values for the
     * currently selected Attribute.
     * @param evt
     */
    private void removeValueActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_removeValueActionPerformed
    {//GEN-HEADEREND:event_removeValueActionPerformed
        //If no attribute is selected return... Should never happen as this button
        //should only be enabled if an attribute is selected
        Attribute att = (Attribute)attributeNames.getSelectedValue();
        if(att == null)
            return;

        //Get Selected values
        Object[] allowables = attributeValues.getSelectedValues();

        //Return if nothing selected
        if(allowables == null || allowables.length == 0)
            return;

        //Remove ALL selcted values
        for(Object allowable: allowables)
            att.getAllowedEntries().remove((String)allowable);
        updateInList(att);
    }//GEN-LAST:event_removeValueActionPerformed

    /**
     * If the user types a new line character into the textbox then add the text
     * as a new attribute name.
     * @param evt
     */
    private void nameTextKeyPressed(java.awt.event.KeyEvent evt)//GEN-FIRST:event_nameTextKeyPressed
    {//GEN-HEADEREND:event_nameTextKeyPressed
        if(evt.getKeyChar() == '\n')
        {
            addNewRelationshipFromTextBox();
        }
    }//GEN-LAST:event_nameTextKeyPressed
 /**
     * If the user types a new line character into the textbox then add the text
     * as a new allowed value for the currently selected attribute.
     * @param evt
     */
    private void valueTextKeyPressed(java.awt.event.KeyEvent evt)//GEN-FIRST:event_valueTextKeyPressed
    {//GEN-HEADEREND:event_valueTextKeyPressed
        if(evt.getKeyChar() == '\n')
        {
            addNewAllowableFromTextBox();
        }
    }//GEN-LAST:event_valueTextKeyPressed
    /**
     * If an attribute value is currently selected enable the remove button, otherwise
     * disable it.
     * @param evt
     */
    private void attributeValuesValueChanged(javax.swing.event.ListSelectionEvent evt)//GEN-FIRST:event_attributeValuesValueChanged
    {//GEN-HEADEREND:event_attributeValuesValueChanged

        if(attributeValues.getSelectedIndex() >= 0)
        {
            removeValue.setEnabled(true);
        }
        else
        {
            removeValue.setEnabled(false);
        }
    }//GEN-LAST:event_attributeValuesValueChanged

    private void attributeNamesMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_attributeNamesMouseReleased
        
        if(evt.getClickCount()!=2)
            return;

        try{
            if(attributeNames.getModel()==null)
                return;

            if(attributeNames.getModel().getSize()<1)
                return;

            int selectedIndex = attributeNames.getSelectedIndex();
            if(selectedIndex == -1)
                return;

            Object value = attributeNames.getSelectedValue();
            if(value==null)
                return;
            Attribute att = (Attribute)value;
            if(att==null)
                return;
            
            popupDialog_toChangeAttributeName(att.getName(), selectedIndex);

        }catch(Exception ex){
        }

        
    }//GEN-LAST:event_attributeNamesMouseReleased


    /**This integer is used to remember the real index in the array where we
     * store current selected attribute. Value smaller than 0 indicates that
     * there is no attribute got selected.
     */
    private int selectedAttribute = -1;
    private String oldAttributeName = null;

    /**This will popup a new dialog to let you change the name of the selected
     * attribute item.
     *
     * @param   _attributeName
     *          The name of current selected attribute item in the schema dialog
     *
     * @param   _index
     *          the position of this selected attributes, the index is its real
     *          index in the arrtibute depot
     */
    private void popupDialog_toChangeAttributeName(String _attributeName, int _index){
        
        this.changeAttributeName.setVisible(false);
        selectedAttribute = _index;
        
        // designate size to this dialog
        final int width = 413, height = 104;
        this.changeAttributeName.setSize(width, height);

        // put this dialog in the middle of current parent dialog
        int x,y;
        int thisx = this.getX(), thisy=this.getY();
        int thiswidth = this.getWidth(), thisheight = this.getHeight();
        x = thisx + ((thiswidth - width)/2);
        y = thisy + ((thisheight - height)/2);

        oldAttributeName = _attributeName;
        jTestField_attributeName.setText(_attributeName);

        this.changeAttributeName.setLocation(x, y);
        this.changeAttributeName.setVisible(true);

    }

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        String newname = jTestField_attributeName.getText();
        if((newname==null)||(newname.trim().length()<1)){
            commons.Tools.beep();
            return;
        }

        this.changeAttributeName.setVisible(false);

        // save the modification we just did to the selected attribute item.
        saveChange(newname.trim());

        // update the list of attribute name
        
    }//GEN-LAST:event_jButton2ActionPerformed

    /**Saving the modification we just did to the selected attribute item. This
     * method should be called after user clicked "Ok" button on the dialog
     * of changing attribute name.
     */
    private void saveChange(String _newAttributeName){
        if(_newAttributeName==null)
            return;
        if(_newAttributeName.trim().length()<1)
            return;

        env.Parameters.SimpleRelationshipNames.rename(oldAttributeName, _newAttributeName);
        
        updateRelationships();        
        nameText.setText("");
        
        
    }

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        this.changeAttributeName.setVisible(false);
    }//GEN-LAST:event_jButton4ActionPerformed
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Private Methods">
    /**put this dialog in the middle of eHOST's main window*/
    private void setDialogLocation()
    {
        //If null was passed into the constructor then just return
        if (gui == null)
        {
            return;
        }

        //If non null gui then center the gui in the Callers window.
        int parentX = gui.getX(), parentY = gui.getY();
        int parentWidth = gui.getWidth(), parentHeight = gui.getHeight();
        int width = this.getWidth(), height = this.getHeight();

        int x = parentX + (int) ((parentWidth - width) / 2);
        int y = parentY + (int) ((parentHeight - height) / 2);

        this.setLocation(x, y);
    }
    /**
     * Update the list of relationship names
     */
    private void updateRelationships()
    {
        Vector<Attribute> listInfo = new Vector<Attribute>();
        for(Attribute att: env.Parameters.SimpleRelationshipNames.getAttributes())
        {
            listInfo.add(att);
        }
        attributeNames.setListData(listInfo);
    }
    /**
     * Update the list of allowable values based on the passed in attribute.
     * @param value - the attribute to display the allowed values
     */
    private void updateInList(Attribute value)
    {
        if(value == null)
            return;
        Vector<String> listData = new Vector<String>();
        for(String s: value.getAllowedEntries())
        {
            listData.add(s);
        }
        attributeValues.setListData(listData);
    }
    /**
     * This method will add a new relationship using the text in the textbox.
     */
    private void addNewRelationshipFromTextBox()
    {
        Attribute toAdd = new Attribute(nameText.getText(), new HashSet<String>());

        boolean reallyNew = true;
        //Don't allow duplicates
        for(Attribute existing: env.Parameters.SimpleRelationshipNames.getAttributes())
        {
            if(existing.getName().equals(toAdd.getName()))
            {
                reallyNew = false;
            }
        }
        if(reallyNew)
        {
            env.Parameters.SimpleRelationshipNames.Add(toAdd);
        }
        updateRelationships();
        attributeValues.setSelectedValue(toAdd, true);
        nameText.setText("");
    }
    /**
     * This method will add a new allowable value using the text in the textbox.
     */
    private void addNewAllowableFromTextBox()
    {
        Attribute selected = (Attribute)attributeNames.getSelectedValue();
        if(selected == null)
            return;
        String text = this.valueText.getText();
        selected.getAllowedEntries().add(text);
        updateInList(selected);
        attributeNames.setSelectedValue(text, true);
        valueText.setText("");
    }
    //</editor-fold>
    
    //<editor-fold defaultstate="collapsed" desc="GUI Member Variables">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addName;
    private javax.swing.JButton addValue;
    private javax.swing.JList attributeNames;
    private javax.swing.JList attributeValues;
    private javax.swing.JDialog changeAttributeName;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTestField_attributeName;
    private javax.swing.JTextField nameText;
    private javax.swing.JButton removeName;
    private javax.swing.JButton removeValue;
    private javax.swing.JTextField valueText;
    // End of variables declaration//GEN-END:variables
    //</editor-fold>
}
